package com.leet.code.simple_array;

/**
 * @description:
 * @author: WYG
 * @time: 2020/11/28 9:38
 */

public class FlipAndInvertImage {
    public int[][] flipAndInvertImage(int[][] A) {
        int temp = 0;
        for (int i = 0; i < A.length; i++) {
            for (int j = 0; j < A[0].length - j - 1; j++) {
                temp = A[i][j];
                A[i][j] = A[i][A[0].length - j - 1];
                A[i][A[0].length - j - 1] = temp;
            }
        }
        for (int i = 0; i < A.length; i++) {
            for (int j = 0; j < A[0].length; j++) {
                if (A[i][j] == 0) {
                    A[i][j] = 1;
                } else {
                    A[i][j] = 0;
                }
            }
        }
        return A;
    }

    public int[][] flipAndInvertImages(int[][] A) {
        int temp = 0;
        for (int i = 0; i < A.length; i++) {
            for (int j = 0; j < A[0].length - j; j++) {
                temp = A[i][j] ^ 1;
                A[i][j] = (A[i][A[0].length - j - 1]^1);
                A[i][A[0].length - j - 1] = (temp) ;

            }
        }
        return A;
    }
}
